/**
 * @desc
 *  通用工具.
 * @使用场景
 *
 * @author  杨晓东[of1081]
 * @company qianmi.com
 * @Date    15/10/21
 **/
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
const const_common_1 = require("../const-common");
var envCode = const_common_1.constCommon['envCode'];
class commonUtil {
    /**
     * 返回正确的信息
     * @returns {{result: string, data: *, message: string}}
     */
    static resultSucess(data) {
        return { result: 'ok', data: data, message: '操作成功' };
    }
    /**
     * 失败的操作．
     * @param data
     * @returns {{result: string, data: *, message: string}}
     */
    static resultfailure(data) {
        return { result: "error", message: data };
    }
    static getEnvCode() {
        let _env = 'test'; //环境无配置,默认当前在开发环境
        if (process.env.NODE_ENV === 'production') {
            _env = envCode.PROD;
        }
        else if (process.env.NODE_ENV === 'gray') {
            _env = envCode.GRAY;
        }
        else if (process.env.NODE_ENV === 'prod') {
            _env = envCode.PROD;
        }
        else if (process.env.NODE_ENV === 'test') {
            _env = envCode.TEST;
        }
        else if (process.env.NODE_ENV === 'dev') {
            _env = envCode.DEV;
        }
        else {
            _env = process.env.NODE_ENV || 'test';
        }
        return _env;
    }
    /**
     * 收集请求头的信息,转换为字符串.
     * @param req
     * @returns {string}
     */
    static collectReqInfo(req) {
        let reqInfo = '当前用户 session:' + req.session.id + ':' + JSON.stringify(req.session) + 'referer:' + req.headers.referer + ' userAgent:' + req.headers['user-agent'];
        return reqInfo;
    }
}
exports.default = commonUtil;
console.info('环境参数值::', process.env.NODE_ENV);
